function throttle(fn, timeout) {
  let time = null;
  return function throttledFn(...args) {
    if (!time || time + timeout < Date.now()) {
      fn(...args);
      time = Date.now();
    }
  };
}

let startTime = Date.now();

const fn = throttle((args) => {
  console.log(args);
  let endTime = Date.now();
  console.log("duration", endTime - startTime);
  startTime = Date.now();
}, 3000);

fn(1111);
fn(222);
fn(333);
setTimeout(() => fn(44), 2000);
setTimeout(() => {
  fn(55);
}, 4000);
